<?php
include('../../include/functions.inc.php');
//drawDebug($_POST);
$intCiclo = getParam('CICLO');
$intCarrera = getParam('CARRERA');
$intCorrelativo = 0;
?>

<table width="100%" cellpadding="0" cellspacing="1" class="table table-striped table-hover table-bordered">
    <tr>
        <th width="10%" align="center"><input type="checkbox" name="chkAsignacionAll" id="chkAsignacionAll" value="1"> TODOS</th>
        <th width="30%">Estudiante</th>
        <th>Mes actual asignado</th>
    </tr>
    <?php
    $strQuery ="SELECT  cllg_student_assign.id idAsignacion,
                        CONCAT_WS(' ',cllg_student.first_name, cllg_student.second_name, cllg_student.last_name) estudiante
                FROM    cllg_student_assign
                        INNER JOIN cllg_student
                            ON  cllg_student_assign.fk_student = cllg_student.id
                WHERE   cllg_student_assign.fk_cycle = {$intCiclo}
                AND     cllg_student_assign.fk_career = {$intCarrera}
                AND     cllg_student_assign.status != 0
                ORDER   BY cllg_student_assign.ID";
    $arrTemp = $db->queryToArray($strQuery);
    
    foreach ($arrTemp as $arrTMP) {
        $intCorrelativo++;
        
        //MES ACTUAL
        $getDate = $db->queryToArray("SELECT *
                                      FROM cllg_student_assign 
                                      WHERE ID = {$arrTMP['idAsignacion']}");
       
        $nameMonthYear  = date('M-Y', strtotime(date($getDate[0]['START_DATE'])));
        
        ?>
    
        <tr class="<?php echo fmod($intCorrelativo, 2) == 0 ? 'data line0' : 'data line1'; ?>">
            <td>
                <input type="checkbox" name="chkAssign[]" class="chkAsignacion" id="chkAsignacion_<?php print $arrTMP['idAsignacion']; ?>" value="<?php print $arrTMP['idAsignacion']; ?>">
            </td>
            <td><?php print $arrTMP['estudiante']; ?></td>
            <td><?php print $nameMonthYear; ?></td>
        </tr>
        <?php
    }
    $db->free_result($db->query_id);
    ?>
</table>
<script language="javascript" type="text/javascript">
    jQuery( function() {
        jQuery("#chkAsignacionAll").click( function() {
            if( jQuery("#chkAsignacionAll").is(':checked') ) {
                jQuery(".chkAsignacion").prop('checked', true);
                jQuery("select.checked").attr("disabled", this.checked);
            }
            else {
                jQuery(".chkAsignacion").prop('checked', false);
            }
        });
    });
</script>